package com.shhic.hhplt.server.bkgrdui;

import java.util.List;

import javax.annotation.Resource;

import com.shhic.hhplt.server.service.ITestComplexQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shhic.hhplt.server.biz.IExportReportHelper;
import com.shhic.hhplt.server.biz.ProductQuery;
import com.shhic.hhplt.server.model.BindingCodeQuery;
import com.shhic.hhplt.server.model.BindingCodeQueryResult;

/**
 * 特定产品数据的导出
 * @author 张文硕
 *
 */
@Controller
@RequestMapping("/bkgrd/specProductData/")
public class BackgroundSpecificProductDataController {
	@Resource IExportReportHelper exportReportHelper;
	@Autowired
	ITestComplexQueryService tcxqService;
	@Resource ProductQuery productQuery;
	
	/**
	 * 导出GS10OBU的重庆发货数据
	 * @param startCode	开始整机条码
	 * @param endCode	结束整机条码
	 * @return
	 */
	@RequestMapping(value = "/exportGs10ChongqingDeliveryData.do", method = RequestMethod.POST,produces = "text/xml;charset=UTF-8")
	@ResponseBody
	public String exportGs10ChongqingDeliveryData(@RequestParam long startCode,@RequestParam long endCode){
		BindingCodeQuery query = new BindingCodeQuery();
		query.setBindingCodeNameListStr("合同序列号");
		query.setConditionCodeName("镭雕条码");
		query.setProductName("GS10 OBU");
		query.setStartCode(Long.toString(startCode));
		query.setEndCode(Long.toString(endCode));
		
		List<BindingCodeQueryResult> queryResult = tcxqService.queryBindingCodeCollection(query);
		return exportReportHelper.exportBindingCodeToExcelFile(queryResult,query);
	}
	
	/**
	 * GS11数据导出
	 * @param startCode
	 * @param endCode
	 * @return
	 */
	@RequestMapping(value = "/exportGs11DeliveryData.do", method = RequestMethod.POST,produces = "text/xml;charset=UTF-8")
	@ResponseBody
	public String exportGs11DeliveryData(@RequestParam String startCode,@RequestParam String endCode){
		BindingCodeQuery query = new BindingCodeQuery();
		query.setBindingCodeNameListStr("合同序列号");
		query.setConditionCodeName("镭雕条码");
		query.setProductName("GS11 OBU");
		query.setStartCode(startCode);
		query.setEndCode(endCode);
		
		List<BindingCodeQueryResult> queryResult = tcxqService.queryBindingCodeCollection(query);
		return exportReportHelper.exportBindingCodeToExcelFile(queryResult,query);
	}
	
	/**
	 * 导出OBU的山西发货数据
	 * @param startCode
	 * @param endCode
	 * @return
	 */
	@RequestMapping(value = "/exportGs11ShanXiDeliveryData.do", method = RequestMethod.POST,produces = "text/xml;charset=UTF-8")
	@ResponseBody
	public String exportGs11ShanXiDeliveryData(@RequestParam String startCode,@RequestParam String endCode){
		BindingCodeQuery query = new BindingCodeQuery();
		query.setBindingCodeNameListStr("truemac,contractSerial,SurfaceNumber");
		query.setConditionCodeName("SurfaceNumber");
		query.setProductName("OBU_tc56");
		query.setStartCode(startCode);
		query.setEndCode(endCode);

		List<BindingCodeQueryResult> queryResult = tcxqService.queryBindingCodeCollection(query);
		return exportReportHelper.exportBindingCodeToExcelFile(queryResult,query);
	}
	
	/**
	 * 导出OBU的广西发货数据
	 * @param startCode
	 * @param endCode
	 * @return
	 */
	@RequestMapping(value = "/exportGs11GuangXiDeliveryData.do", method = RequestMethod.POST,produces = "text/xml;charset=UTF-8")
	@ResponseBody
	public String exportGs11GuangXiDeliveryData(@RequestParam String startCode,@RequestParam String endCode){
		BindingCodeQuery query = new BindingCodeQuery();
		query.setBindingCodeNameListStr("truemac");
		query.setConditionCodeName("SurfaceNumber");
		query.setProductName("OBU_tc56");
		query.setStartCode(startCode);
		query.setEndCode(endCode);

		List<BindingCodeQueryResult> queryResult = tcxqService.queryBindingCodeCollection(query);
		return exportReportHelper.exportBindingCodeToExcelFile(queryResult,query);
	}		
	
	/**
	 * 导出OBU的山东发货数据
	 * @param startCode
	 * @param endCode
	 * @return
	 */
	@RequestMapping(value = "/exportGs11ShanDongDeliveryData.do", method = RequestMethod.POST,produces = "text/xml;charset=UTF-8")
	@ResponseBody
	public String exportGs11ShanDongDeliveryData(@RequestParam String startCode,@RequestParam String endCode){
		BindingCodeQuery query = new BindingCodeQuery();
		query.setBindingCodeNameListStr("truemac");
		query.setConditionCodeName("SurfaceNumber");
		query.setProductName("OBU_tc56");
		query.setStartCode(startCode);
		query.setEndCode(endCode);

		List<BindingCodeQueryResult> queryResult = tcxqService.queryBindingCodeCollection(query);
		return exportReportHelper.exportBindingCodeToExcelFile(queryResult,query);
	}	
}
